{% extends "domain_base.html" %}
{% block domain_content %}
<div style="display: none" class="dialog__body--create-role">
  <div>
    <div class="row"><div class="columns">
      <h1>{{ _('Create Role') }}</h1>
    </div></div>
    <div class="row"><div class="columns">
      <blockquote class="note">
        <p>{{ _('Role name can only contains numbers, letters and underscores.') }}</p>
      </blockquote>
      {{ form.form_text({
           columns:None,
           label:'Name',
           name:'role',
           autofocus:true
         }) }}
    </div></div>
  </div>
</div>
<div class="section">
  <div class="section__header">
    <h1 class="section__title">{{ _('{0}: Roles').format(domain.name) }}</h1>
    <div class="section__tools">
      <button class="primary rounded button" name="create_role">{{ _('Create Role') }}</button>
    </div>
  </div>
  {{ noscript_note.render() }}
  <div class="section__body no-padding domain-roles">
    <table class="data-table">
      <colgroup>
        <col class="col--checkbox">
        <col class="col--id">
        <col class="col--users">
      </colgroup>
      <thead>
        <tr>
          <th class="col--checkbox">
            <label class="compact checkbox">
              <input type="checkbox" data-checkbox-toggle="role">
            </label>
          </th>
          <th class="col--id">{{ _('Role') }}</th>
          <th class="col--users">{{ _('Users') }}</th>
        </tr>
      </thead>
      <tbody>
      {%- for role in roles -%}
        {% set isBuiltin = role._id in ['default', 'guest', 'root'] %}
        <tr{% if not isBuiltin %} data-role="{{ role._id }}"{% endif %}>
          <td class="col--checkbox">
            <label class="compact checkbox">
              <input type="checkbox" data-checkbox-group="role" {{ "disabled" if isBuiltin else "data-checkbox-range" }}>
            </label>
          </td>
          <td class="col--id">
            {{ _('Built-in') if isBuiltin else _('User-defined role') }}: {{ role._id }}
          </td>
          <td class="col--users">
            {{ role.count|default('--') }}
          </td>
        </tr>
      {%- endfor -%}
      </tbody>
    </table>
  </div>
  <div class="section__body">
    <button class="rounded button" name="delete_selected">{{ _('Delete Selected Roles') }}</button>
  </div>
</div>
{% endblock %}
